/**
 * jims
 */
package com.jims.api.v1.controller.patient;

import com.jims.master.common.data.StringData;
import com.jims.master.common.persistence.Page;
import com.jims.master.common.utils.DateUtils;
import com.jims.master.common.utils.SecurityUtil;
import com.jims.master.common.utils.StringUtils;
import com.jims.master.common.web.BaseController;
import com.jims.master.modules.base.user.entity.ExamPresentation;
import com.jims.master.modules.base.user.service.ExamPresentationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import com.jims.master.common.data.Message;
import java.util.Date;
import java.util.List;

/**
 * Controller
 * @author 系统管理员
 * @version 2018-07-12
 */
@RestController
@RequestMapping(value = "/examPresentation")
public class ExamPresentationController extends BaseController {

	@Autowired
	private ExamPresentationService examPresentationService;

	@RequiresPermissions("user")
	@RequestMapping(value = "save")
	@ResponseBody
	public StringData save(ExamPresentation examPresentation, Model model) {
	    StringData data=new StringData();
		examPresentation.setResuoce("1");
	    if(examPresentation.getReporttime().equals("")){
			examPresentation.setReporttime(DateUtils.formatDate(new Date()));
		}
		if(examPresentation.getReviewtime().equals("")){
			examPresentation.setReviewtime(DateUtils.formatDate(new Date()));
		}
		if(examPresentation.getChecktime().equals("")){
			examPresentation.setChecktime(DateUtils.formatDate(new Date()));
		}
		if(examPresentation.getEnroltime().equals("")){
			examPresentation.setEnroltime(DateUtils.formatDate(new Date()));
		}
		int i=examPresentationService.save(examPresentation);
        if(i>0){
            data.setCode("success");
            data.setData("保存成功");
        }else{
            data.setCode("error");
            data.setData("保存失败");
        }
        return data;
	}

	/***
	 * 查找pasc
	 * @return
	 */
	@RequestMapping(value = "/V100/getPasc",method ={RequestMethod.GET,RequestMethod.POST})
	public String getInfo(String accessionno) {
		List<ExamPresentation> examPresentation = examPresentationService.getPasc(accessionno);
		Message mes = new Message();
		mes.setData(examPresentation);
		return SecurityUtil.encryptMsgData(mes);
	}

}